%{
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
%}

%token SEMICOLON OPEN_BRACKET CLOSE_BRACKET OPEN_CURLY CLOSE_CURLY WORD NUMBER

%%

specs:	| spec
	{
		ast_result = create_token(SPEC);
		ast_result->child = $1;
		ast_result->next = NULL;
		$$ = ast_result;
	}
	| specs spec
	{
		ast_result = create_token(SPEC);
		ast_result->child = $2;
		ast_result->next = $1;
		$$ = ast_result;
	}
;

spec:
	block | expr
;

value:
	WORD | NUMBER
;

expr:
	WORD value SEMICOLON
	{
		$$ = create_token(EXPR);
		$$->stringValue = $1->stringValue;
		$$->child = $2;
	}
;

block:
	WORD OPEN_BRACKET value CLOSE_BRACKET OPEN_CURLY specs CLOSE_CURLY
	{
		$$ = create_token(BLOCK);
		$$->stringValue = $1->stringValue;
		$$->child = $3;
		$$->child->next = $6;
	}
;

%%
